﻿using System;

namespace FluentExport.Example
{
    class Program
    {
        static void Main()
        {
            CSVWithSimpleSource();
            CSVWithCompoundSource();
            CSVWithSimpleListSource();
            CSVDefineHeadersExampleHeaderMethods();
            CSVDefineHeadersExampleHeadersMethod();
        }

        static void CSVWithSimpleSource()
        {
            var csvExport = CSVExport.CSVExport.Init();

            csvExport.CreateSource<Player>(p => p.Name)
                     .CreateSource<Player>(p => p.LastName)
                     .CreateSource<Player>(p => p.Age)
                     .CreateSource<Player>(p => p.Comments);

            var player = new Player { Name = "Matias", LastName = "Paz", Age = 26, Comments = "This person is good-looking, tall, slim and lazy" };

            var csv = csvExport.Export(player);

            Console.WriteLine("CSV export simple properties:");
            Console.WriteLine(csv.ToString());
            Console.ReadLine();
        }

        static void CSVWithSimpleListSource()
        {
            var csvExport = CSVExport.CSVExport.Init();

            csvExport.CreateSource<Player>(p => p.Name, p => p.LastName, p => p.Age);

            var player = new Player { Name = "Matias", LastName = "Paz", Age = 26 };

            var csv = csvExport.Export(player);

            Console.WriteLine("CSV export simple properties:");
            Console.WriteLine(csv.ToString());
            Console.ReadLine();
        }

        static void CSVWithCompoundSource()
        {
            var csvExport = CSVExport.CSVExport.Init();

            csvExport.CreateCompoundSource<Player>().Add(p => p.Name)
                                                    .Add(p => p.LastName)
                                                    .WithFormat("{0}, {1}");

            var player = new Player { Name = "Matias", LastName = "Paz" };

            var csv = csvExport.Export(player);

            Console.WriteLine("CSV export complex properties:");
            Console.WriteLine(csv.ToString());
            Console.ReadLine();
        }

        static void CSVDefineHeadersExampleHeaderMethods()
        {
            var csvExport = CSVExport.CSVExport.Init();

            csvExport.Header("Player Name")
                     .Header("Player Lastname") 
                     .CreateSource<Player>(p => p.Name)
                     .CreateSource<Player>(p => p.LastName);

            var player = new Player { Name = "Matias", LastName = "Paz" };

            var csv = csvExport.Export(player);

            Console.WriteLine("CSV export header method:");
            Console.WriteLine(csv.ToString());
            Console.ReadLine();
        }

        static void CSVDefineHeadersExampleHeadersMethod()
        {
            var csvExport = CSVExport.CSVExport.Init();

            csvExport.Headers("Player Name", "Player Lastname")
                     .CreateSource<Player>(p => p.Name, p => p.LastName);

            var player = new Player { Name = "Matias", LastName = "Paz" };

            var csv = csvExport.Export(player);

            Console.WriteLine("CSV export headers method:");
            Console.WriteLine(csv.ToString());
            Console.ReadLine();
        }

    }
}
